home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_300
/
329_01
/
tr.doc
< prev
next >
Wrap
Text File
|
1988-12-07
|
1KB
|
39 lines
TR
Purpose
transliterate characters
Syntax
tr [-bcds] [inset [outset]]
Comments
Tr is a filter (it reads from the standard input and writes to the
standard output) which can substitute for or delete selected characters.
Input characters which are in string inset are mapped to characters in
string outset. If outset is shorter than the length of inset, it is
padded to that length with its last character.
Inset and outset may contain ranges of characters in the form a-b, where
a and/or b may be omitted, and octal numbers of the form \ooo, where ooo
is 1-3 octal digits. Combining the two (e.g., \1-\5) is allowed. '\'
followed by a character other than an octal digit is simply translated
to that character. Nulls are acceptable both in the input stream and in
the arguments (in the form of an octal escape).
Options:
-b operate in binary mode (default is text mode)
-c complement inset with respect to 1-0377 octal (in ASCII order)
-d delete all occurrences of characters in inset
-s squeeze repeated characters in outset to single character on output
Examples:
Create a list of all the words in infile, one per line, in outfile,
where a word is taken to be a maximal string of alphabetics (012 is the
ASCII code for newline):
tr -cs A-Za-z \012 < infile > outfile
Copy infile to outfile with all nonprinting characters removed:
tr -d \1-\11\13-\37\177-\377 < infile > outfile